package cn._2dland.gae.httpclient;

import java.util.ArrayList;
import java.util.List;

public class HttpCookie {
	private List<Cookie> cookies = new ArrayList<Cookie>();

	public HttpCookie() {
	}

	public boolean isEmpty() {
		return (cookies==null || cookies.isEmpty());
	}

	/** 添加cookie */
	public void addCookie(Cookie c) {
		cookies.add(c);
	}
	public void addCookies(List<Cookie> c) {
		cookies.addAll(c);
	}

	/** 清空Cookie */
	public void clear() {
		cookies.clear();
	}

	public String toString() {
		if(cookies == null || cookies.size() == 0) 
			return "";

		StringBuffer cookieBuf = new StringBuffer();
		String sep = "";
		for(int i=0; i<cookies.size(); i++) {
			Cookie c = cookies.get(i);
			cookieBuf.append(sep).append(c.name).append("=").append(c.value);
			sep = "; ";
		}
		return cookieBuf.toString();
	}
}
